package com.jww.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/demo01")
public class demo01 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String contextPath = req.getContextPath();
        System.out.println("contextPath = " + contextPath);

        String servletPath = req.getServletPath();
        System.out.println("servletPath = " + servletPath);

        String remoteAddr = req.getRemoteAddr();
        System.out.println("remoteAddr = " + remoteAddr);

        //获取指定头信息
        String referer = req.getHeader("Referer");
        System.out.println("referer = " + referer);

        String Uesr_Agent_header = req.getHeader("User-Agent");
        System.out.println("Uesr_Agent_header = " + Uesr_Agent_header);


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
